import { createRouter, createWebHistory } from 'vue-router'
import { routerData } from "./router";
import { useRouteStore } from "@/stores/router";
import pinia from '@/stores'
const routeStore = useRouteStore(pinia);
routeStore.addRoute(routerData);

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      redirect: '/workbench',
      component: () => import('@/layout/index.vue'),
      children: [
        ...routeStore.route,
        //添加独立路由
        {
          path: '/workbench/ordering/ordering/:orderId',
          name: 'ordering',
          component: () => import('@/views/workbench/ordering/ordering.vue'),
          meta: {
            key: route => route.fullPath
          }
        },
        {
          path: '/workbench/ordering/payment/:orderId',
          name: 'payment',
          component: () => import('@/views/workbench/ordering/payment.vue')
        }
      ]
    }
  ]
})

export default router
